home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 342_01.zip / DIOFNC02.C < prev    next >
C/C++ Source or Header  |  1993-04-03  |  2KB  |  60 lines

  1. /*-
  2.  *  ----------------------------------------------------------------------
  3.  *  File        :   DIOFNC02.C
  4.  *  Creator     :   Blake Miller
  5.  *  Version     :   01.01.00        February 1991
  6.  *  Language    :   Microsoft C     Version 5.1
  7.  *  Purpose     :   Intel 8255 Compatible Digital IO Functions
  8.  *                  Set 8255 Mode Function
  9.  *  ----------------------------------------------------------------------
  10.  *  Revision History:
  11.  *  022891 BVM  :   Change int to short.
  12.  *  070490 BVM  :   Creation
  13.  *  ----------------------------------------------------------------------
  14.  */
  15.  
  16. #define     DIOFNC02_C_DEFINED  1
  17. #include    "DIOLIB.H"
  18. #undef      DIOFNC02_C_DEFINED
  19.  
  20. void dio_config (DIODAT *, short, short, short, short);
  21.  
  22. /*- DIO : Configure --------------------------**
  23.  *  Configure the 8255 for all ports in Mode 0.
  24.  *  Pass a short representing the IN or OUT state for each port.
  25.  *  TRUE (!0) will mean input, and FALSE (0) will mean output.
  26.  *  Passed:
  27.  *      pointer :   DIODAT
  28.  *      short   :   direction Port A
  29.  *      short   :   direction Port B
  30.  *      short   :   direction Port C Low
  31.  *      short   :   direction Port C High
  32.  *  Returns:
  33.  *      nothing
  34.  */
  35. void dio_config (DIODAT *data, short pa_dir, short pb_dir,
  36.                                short cl_dir, short ch_dir)
  37.     {
  38.  
  39.     /*  Initially set mode to DIO_SET since we are
  40.      *  going to configure the 8255.
  41.      *  Then OR in the IO direction bits as appropriate.
  42.      */
  43.  
  44.     data->mode = DIO_SET;
  45.  
  46.     if ( pa_dir )   data->mode |= DIO_PA_IN;
  47.     if ( pb_dir )   data->mode |= DIO_PB_IN;
  48.     if ( cl_dir )   data->mode |= DIO_CL_IN;
  49.     if ( ch_dir )   data->mode |= DIO_CH_IN;
  50.  
  51.     dio_bput ( data->base + DIO_CNTRL, data->mode );
  52.     data->stat = DIO_ST_OK;
  53.     }
  54.  
  55. /*-
  56.  *  ----------------------------------------------------------------------
  57.  *  END DIOFNC02.C Source File
  58.  *  ----------------------------------------------------------------------
  59.  */
  60.